
<!DOCTYPE html>
<html>
  <head>
    <title>prototype</title>
    <link rel="stylesheet" href="prism.css">
    <link rel="stylesheet" href="style.css">
  </head>
  <body>
    <div id="header">
      <div class="doc-title"><a href="folktale.html"><span class="doc-title"><span class="product-name">Folktale</span><span class="version">v2.0.1</span></span></a><ul class="navigation"><li class="navigation-item"><a href="https://github.com/origamitower/folktale" title="">GitHub</a></li><li class="navigation-item"><a href="folktale.html#cat-2-support" title="">Support</a></li><li class="navigation-item"><a href="folktale.html#cat-3-contributing" title="">Contributing</a></li></ul></div>
    </div>
    <div id="content-wrapper"><div id="content-panel"><h1 class="entity-title">prototype</h1><div class="highlight-summary"><div><p>The container for instance methods for Ok variants of the Result structure.</p>
</div></div><div class="deprecation-section"><strong class="deprecation-title">This feature is experimental!</strong><p>This API is still experimental, so it may change or be removed in future versions. You should not rely on it for production applications.</p></div><h2 class="section-title">Documentation</h2><div class="documentation"><div><p>The container for instance methods for Ok variants of the Result structure.</p>
</div></div><div class="members"><h2 class="section-title" id="properties">Properties</h2><div class="member-category"><h3 class="category" id="cat-combining">Combining</h3><div class="member-list"><div class="member"><a class="member-name" href="folktale.result.result.concat-1.html">concat()</a><div class="doc-summary"><div><p>Combines two Results such that if they&#39;re both successful (<code>Ok</code>) their values are
concatenated. Otherwise returns the failure.</p>
</div></div><div class="special-tags"></div></div></div></div><div class="member-category"><h3 class="category" id="cat-comparing-and-testing">Comparing and testing</h3><div class="member-list"><div class="member"><a class="member-name" href="-unknown-module-.folktale.result.error.prototype.variants.1.prototype.equals.html">equals(value)</a><div class="doc-summary"><div><p>Performs a deep-comparison of two Result values for equality. See <code>adt/union/derivations/equality</code> for details.</p>
</div></div><div class="special-tags"><span class="tagged experimental">Experimental</span></div></div><div class="member"><a class="member-name" href="-unknown-module-.folktale.result.hasinstance.html">hasInstance(value)</a><div class="doc-summary"><div><p>Tests if an arbitrary value is a Result instance.</p>
</div></div><div class="special-tags"><span class="tagged experimental">Experimental</span><span class="tagged inherited">Inherited</span></div></div><div class="member deprecated"><a class="member-name" href="-unknown-module-.folktale.result.error.prototype.variants.1.prototype.isok.html">get isOk</a><div class="doc-summary"><div><p>True if the value is a <code>Ok</code> instance.</p>
</div></div><div class="special-tags"><span class="tagged deprecated">Deprecated</span></div></div></div></div><div class="member-category"><h3 class="category" id="cat-constructing">Constructing</h3><div class="member-list"><div class="member"><a class="member-name" href="folktale.result.result.of.html">of(value)</a><div class="doc-summary"><div><p>Constructs a Result holding an Ok value.</p>
</div></div><div class="special-tags"><span class="tagged experimental">Experimental</span><span class="tagged inherited">Inherited</span></div></div></div></div><div class="member-category"><h3 class="category" id="cat-converting-to-other-types">Converting to other types</h3><div class="member-list"><div class="member"><a class="member-name" href="folktale.result.result.tomaybe.html">toMaybe()</a><div class="doc-summary"><div><p>Transforms a Result into a Maybe. Error values are lost in the process.</p>
</div></div><div class="special-tags"><span class="tagged experimental">Experimental</span><span class="tagged inherited">Inherited</span></div></div><div class="member"><a class="member-name" href="folktale.result.result.tovalidation.html">toValidation()</a><div class="doc-summary"><div><p>Transforms a Result into a Validation.</p>
</div></div><div class="special-tags"><span class="tagged experimental">Experimental</span><span class="tagged inherited">Inherited</span></div></div></div></div><div class="member-category"><h3 class="category" id="cat-data-fields">Data fields</h3><div class="member-list"><div class="member"><a class="member-name" href="folktale.result.result.value-1.html">get value</a><div class="doc-summary"><div><p>The value contained in an Ok instance of the Result structure.</p>
</div></div><div class="special-tags"><span class="tagged required">Abstract</span></div></div></div></div><div class="member-category"><h3 class="category" id="cat-debugging">Debugging</h3><div class="member-list"><div class="member"><a class="member-name" href="-unknown-module-.folktale.result.error.prototype.variants.1.prototype.inspect.html">inspect: toString()</a><div class="doc-summary"><div><p>A textual representation for Result instances.</p>
</div></div><div class="special-tags"><span class="tagged experimental">Experimental</span></div></div><div class="member"><a class="member-name" href="-unknown-module-.folktale.result.error.prototype.variants.1.prototype.inspect.html">toString()</a><div class="doc-summary"><div><p>A textual representation for Result instances.</p>
</div></div><div class="special-tags"><span class="tagged experimental">Experimental</span></div></div></div></div><div class="member-category"><h3 class="category" id="cat-extracting-values">Extracting values</h3><div class="member-list"><div class="member deprecated"><a class="member-name" href="folktale.result.result.get.html">get()</a><div class="doc-summary"><div><p>This method has been renamed to <code>unsafeGet()</code>.</p>
</div></div><div class="special-tags"><span class="tagged deprecated">Deprecated</span><span class="tagged inherited">Inherited</span></div></div><div class="member"><a class="member-name" href="folktale.result.result.getorelse-1.html">getOrElse()</a><div class="doc-summary"><div><p>Extracts the value of a <code>Result</code> structure, if it exists (i.e.: is an <code>Ok</code>),
otherwise returns the provided default value.</p>
</div></div><div class="special-tags"><span class="tagged experimental">Experimental</span></div></div><div class="member"><a class="member-name" href="folktale.result.result.merge.html">merge()</a><div class="doc-summary"><div><p>Returns the value inside of the Result structure, regardless of its state.</p>
</div></div><div class="special-tags"><span class="tagged experimental">Experimental</span><span class="tagged inherited">Inherited</span></div></div><div class="member"><a class="member-name" href="folktale.result.result.unsafeget-1.html">unsafeGet()</a><div class="doc-summary"><div><p>Extracts the value from a <code>Result</code> structure.</p>
</div></div><div class="special-tags"><span class="tagged experimental">Experimental</span></div></div></div></div><div class="member-category"><h3 class="category" id="cat-fantasy-land">Fantasy Land</h3><div class="member-list"><div class="member"><a class="member-name" href="-unknown-module-.folktale.concurrency.future._future.ap.html">ap(that)</a><div class="doc-summary"><div><p>Part of the Applicative instance for Fantasy Land 1.x. See the <code>apply</code> method for details.</p>
</div></div><div class="special-tags"></div></div><div class="member"><a class="member-name" href="-unknown-module-.folktale.concurrency.future._future.fantasy-land-ap.html">fantasy-land/ap(that)</a><div class="doc-summary"><div><p>Part of the Applicative instance for Fantasy Land 2.x+. See the <code>apply</code> method for details.</p>
</div></div><div class="special-tags"></div></div><div class="member"><a class="member-name" href="-unknown-module-.folktale.concurrency.future._future.prototype.fantasy-land-bimap.html">fantasy-land/bimap(f, g)</a><div class="doc-summary"><div><p>Part of the Bifunctor instance for Fantasy Land 2.x+. See the <code>bimap</code> method for details.</p>
</div></div><div class="special-tags"></div></div><div class="member"><a class="member-name" href="-unknown-module-.folktale.concurrency.future._future.prototype.fantasy-land-chain.html">fantasy-land/chain(transformation)</a><div class="doc-summary"><div><p>Part of the Monad instance for Fantasy Land 2.x+. See the <code>chain</code> method for details.</p>
</div></div><div class="special-tags"></div></div><div class="member"><a class="member-name" href="-unknown-module-.folktale.maybe.just.prototype.fantasy-land-concat.html">fantasy-land/concat(that)</a><div class="doc-summary"><div><p>Part of the Semigroup instance for Fantasy Land 2.x+. See the <code>concat</code> method for details.</p>
</div></div><div class="special-tags"></div></div><div class="member"><a class="member-name" href="-unknown-module-.folktale.concurrency.future._executionstate.variants.0.prototype.fantasy-land-equals.html">fantasy-land/equals(that)</a><div class="doc-summary"><div><p>Part of the Setoid instance for Fantasy Land 2.x+. See the <code>equals</code> method for details.</p>
</div></div><div class="special-tags"></div></div><div class="member"><a class="member-name" href="-unknown-module-.folktale.concurrency.future._future.prototype.fantasy-land-map.html">fantasy-land/map(transformation)</a><div class="doc-summary"><div><p>Part of the Functor instance for Fantasy Land 2.x+. See the <code>map</code> method for details.</p>
</div></div><div class="special-tags"></div></div><div class="member"><a class="member-name" href="-unknown-module-.folktale.concurrency.future._future.fantasy-land-of.html">fantasy-land/of(value)</a><div class="doc-summary"><div><p>Part of the Applicative instance for Fantasy Land 2.x+. See the <code>of</code> method for details.</p>
</div></div><div class="special-tags"></div></div></div></div><div class="member-category"><h3 class="category" id="cat-meta-programming">Meta-programming</h3><div class="member-list"><div class="member"><a class="member-name" href="folktale.adt.union.union.derive.html">derive(...derivations)</a><div class="doc-summary"><div><p>Allows a function to provide functionality to variants in an union.</p>
</div></div><div class="special-tags"><span class="tagged experimental">Experimental</span><span class="tagged inherited">Inherited</span></div></div></div></div><div class="member-category"><h3 class="category" id="cat-pattern-matching">Pattern matching</h3><div class="member-list"><div class="member"><a class="member-name" href="folktale.result.result.fold-1.html">fold()</a><div class="doc-summary"><div><p>Applies a function to each case of a Result.</p>
</div></div><div class="special-tags"><span class="tagged experimental">Experimental</span></div></div><div class="member"><a class="member-name" href="-unknown-module-.folktale.result.error.prototype.variants.1.prototype.matchwith.html">matchWith(pattern)</a><div class="doc-summary"><div><p>Chooses and executes a function for each variant in the Result structure.</p>
</div></div><div class="special-tags"><span class="tagged experimental">Experimental</span></div></div></div></div><div class="member-category"><h3 class="category" id="cat-recovering-from-errors">Recovering from errors</h3><div class="member-list"><div class="member"><a class="member-name" href="folktale.result.result.orelse-1.html">orElse()</a><div class="doc-summary"><div><p>Allows recovering from <code>Error</code> values with a handler function.</p>
</div></div><div class="special-tags"><span class="tagged experimental">Experimental</span></div></div><div class="member"><a class="member-name" href="folktale.result.result.swap-1.html">swap()</a><div class="doc-summary"><div><p>Inverts the context of a Result value such that Errors are transformed into Oks,
and Oks are transformed into Errors. Does not touch the value inside of the
Result.</p>
</div></div><div class="special-tags"><span class="tagged experimental">Experimental</span></div></div></div></div><div class="member-category"><h3 class="category" id="cat-serialising">Serialising</h3><div class="member-list"><div class="member"><a class="member-name" href="-unknown-module-.folktale.result.fromjson.html">fromJSON(value, parsers = {
  [typeName]: adt
}, keysIndicateType = false)</a><div class="doc-summary"><div><p>Parses a JavaScript object previously serialised as <code>aResult.toJSON()</code> into a proper Result structure.</p>
</div></div><div class="special-tags"><span class="tagged experimental">Experimental</span><span class="tagged inherited">Inherited</span></div></div><div class="member"><a class="member-name" href="-unknown-module-.folktale.result.error.prototype.variants.1.prototype.tojson.html">toJSON()</a><div class="doc-summary"><div><p>Converts a Result value to a JavaScript object that may be stored as a JSON value.</p>
</div></div><div class="special-tags"><span class="tagged experimental">Experimental</span></div></div></div></div><div class="member-category"><h3 class="category" id="cat-special-values">Special values</h3><div class="member-list"><div class="member"><a class="member-name" href="folktale.adt.union.union.constructor-7.html">get constructor</a><div class="doc-summary"><div><p>The constructor for this variant.</p>
</div></div><div class="special-tags"></div></div><div class="member"><a class="member-name" href="-unknown-module-.folktale.result.error.prototype.variants.html">variants</a><div class="doc-summary"><div><p>The variants in the Result structure.</p>
</div></div><div class="special-tags"><span class="tagged experimental">Experimental</span><span class="tagged inherited">Inherited</span></div></div></div></div><div class="member-category"><h3 class="category" id="cat-transforming">Transforming</h3><div class="member-list"><div class="member"><a class="member-name" href="folktale.result.result.apply.html">apply()</a><div class="doc-summary"><div><p>Applies the function contained in one Result to the value in another Result.
Application only occurs if both Results are <code>Ok</code>, otherwise keeps the first
<code>Error</code>.</p>
</div></div><div class="special-tags"><span class="tagged experimental">Experimental</span></div></div><div class="member"><a class="member-name" href="folktale.result.result.bimap.html">bimap()</a><div class="doc-summary"><div><p>Transforms each side of a Result with a function, without changing the context
of the computation. That is, Errors will still be Errors, Oks will still be
Oks.</p>
</div></div><div class="special-tags"><span class="tagged experimental">Experimental</span></div></div><div class="member"><a class="member-name" href="folktale.result.result.chain.html">chain()</a><div class="doc-summary"><div><p>Transforms the value and context of a Result computation with an unary function.
As with <code>.map()</code>, the transformation is only applied if the value is an <code>Ok</code>,
but the transformation is expected a new <code>Result</code> value, which then becomes the
result of the method.</p>
</div></div><div class="special-tags"><span class="tagged experimental">Experimental</span></div></div><div class="member"><a class="member-name" href="folktale.result.result.filter.html">filter()</a><div class="doc-summary"><div><p>If the Result is a Ok, passes its value to the predicate. If the predicate
returns true, then the Result is returned unchanged. In every other case,
an Error gets returned.</p>
</div></div><div class="special-tags"><span class="tagged experimental">Experimental</span></div></div><div class="member"><a class="member-name" href="folktale.result.result.map.html">map()</a><div class="doc-summary"><div><p>Transforms the value inside of a Result structure with an unary function without
changing the context of the computation. That is, <code>Error</code> values continue to be
<code>Error</code> values, and <code>Ok</code> values continue to be <code>Ok</code> values.</p>
</div></div><div class="special-tags"><span class="tagged experimental">Experimental</span></div></div><div class="member"><a class="member-name" href="folktale.result.result.maperror.html">mapError()</a><div class="doc-summary"><div><p>Transforms the value inside an Error without changing the context of the
computation.</p>
</div></div><div class="special-tags"><span class="tagged experimental">Experimental</span></div></div></div></div><div class="member-category"><h3 class="category" id="cat-variants">Variants</h3><div class="member-list"><div class="member"><a class="member-name" href="folktale.result.result.error.html">Error(value)</a><div class="doc-summary"><div><p>Constructs a Result whose value represents a failure.</p>
</div></div><div class="special-tags"><span class="tagged experimental">Experimental</span><span class="tagged inherited">Inherited</span></div></div><div class="member"><a class="member-name" href="folktale.result.result.1.html">Ok(value)</a><div class="doc-summary"><div><p>Constructs a Result whose value represents a success.</p>
</div></div><div class="special-tags"><span class="tagged experimental">Experimental</span><span class="tagged inherited">Inherited</span></div></div></div></div></div><div class="source-code"><h2 class="section-title" id="source-code">Source Code</h2><div class="source-location">Defined in source/adt/union/union.js at line 95, column 25</div><pre class="source-code"><code class="language-javascript">InternalConstructor.prototype</code></pre></div></div><div id="meta-panel"><div class="meta-section"><div class="meta-field"><strong class="meta-field-title">Stability</strong><div class="meta-field-value">experimental</div></div><div class="meta-field"><strong class="meta-field-title">Licence</strong><div class="meta-field-value">MIT</div></div><div class="meta-field"><strong class="meta-field-title">Module</strong><div class="meta-field-value">folktale/adt/union/union</div></div></div><div class="table-of-contents"><div class="meta-section-title">On This Page</div><ul class="toc-list level-1"><li class="toc-item"><span class="no-anchor">Documentation</span><ul class="toc-list level-2"></ul></li><li class="toc-item"><a href="#properties">Properties</a><ul class="toc-list level-2"><li class="toc-item"><a href="#cat-combining">Combining</a></li><li class="toc-item"><a href="#cat-comparing-and-testing">Comparing and testing</a></li><li class="toc-item"><a href="#cat-constructing">Constructing</a></li><li class="toc-item"><a href="#cat-converting-to-other-types">Converting to other types</a></li><li class="toc-item"><a href="#cat-data-fields">Data fields</a></li><li class="toc-item"><a href="#cat-debugging">Debugging</a></li><li class="toc-item"><a href="#cat-extracting-values">Extracting values</a></li><li class="toc-item"><a href="#cat-fantasy-land">Fantasy Land</a></li><li class="toc-item"><a href="#cat-meta-programming">Meta-programming</a></li><li class="toc-item"><a href="#cat-pattern-matching">Pattern matching</a></li><li class="toc-item"><a href="#cat-recovering-from-errors">Recovering from errors</a></li><li class="toc-item"><a href="#cat-serialising">Serialising</a></li><li class="toc-item"><a href="#cat-special-values">Special values</a></li><li class="toc-item"><a href="#cat-transforming">Transforming</a></li><li class="toc-item"><a href="#cat-variants">Variants</a></li></ul></li><li class="toc-item"><a href="#source-code">Source Code</a></li></ul></div><div class="meta-section"><strong class="meta-section-title">Authors</strong><div class="meta-field"><strong class="meta-field-title">Copyright</strong><div class="meta-field-value">(c) 2013-2017 Quildreen Motta, and CONTRIBUTORS</div></div><div class="meta-field"><strong class="meta-field-title">Authors</strong><div class="meta-field-value"><ul class="meta-list"><li>Quildreen Motta</li></ul></div></div><div class="meta-field"><strong class="meta-field-title">Maintainers</strong><div class="meta-field-value"><ul class="meta-list"><li>Quildreen Motta &lt;queen@robotlolita.me&gt; (http://robotlolita.me/)</li></ul></div></div></div></div></div>
    <script>
void function() {
  var xs = document.querySelectorAll('.documentation pre code');
  for (var i = 0; i < xs.length; ++i) {
    xs[i].className = 'language-javascript code-block';
  }
}()
    </script>
    <script src="prism.js"></script>
  </body>
</html>